Skip to content

Expose CIMD config in MCPExternalAuthConfig CRD#5384

Open
amirejaz wants to merge 7 commits into
mainfrom
cimd-phase2-pr5-crd-field
Open

Expose CIMD config in MCPExternalAuthConfig CRD#5384
amirejaz wants to merge 7 commits into
mainfrom
cimd-phase2-pr5-crd-field

Conversation

@amirejaz
Copy link
Copy Markdown
Contributor

Summary

  • Stacked on Wire CIMD config through embedded AS and enable storage decorator #5348. Merge that first.
  • Resolves the TODO(cimd) left in PR Wire CIMD config through embedded AS and enable storage decorator #5348: CIMD config is now exposed in the MCPExternalAuthConfig CRD so Kubernetes operators can enable it through a normal VirtualMCPServer manifest instead of writing runconfig.json directly.
  • Adds EmbeddedAuthServerCIMDConfig struct to the CRD API with enabled, cacheMaxSize, and cacheFallbackTtl fields, following the same patterns as existing fields (TokenLifespanConfig for durations, kubebuilder markers for validation).
  • Wires the new CRD field through BuildAuthServerRunConfig in controllerutil/authserver.go, parsing cacheFallbackTtl from a Go duration string to time.Duration.
  • Regenerates zz_generated.deepcopy.go and CRD YAML manifests.

Usage example after this PR:

spec:
  externalAuth:
    type: embeddedAuthServer
    embeddedAuthServer:
      issuer: https://auth.example.com
      upstreamProviders: [...]
      cimd:
        enabled: true
        cacheMaxSize: 256
        cacheFallbackTtl: "5m"

Type of change

  • New feature

Test plan

  • go test ./cmd/thv-operator/pkg/controllerutil/... — new TestBuildAuthServerRunConfig_CIMD covers nil, disabled, enabled with values, enabled with zero fields, invalid TTL
  • go build ./... passes
  • task lint-fix clean
  • CRD YAML regenerated — cimd block appears in both mcpexternalauthconfigs and virtualmcpservers CRDs

Generated with Claude Code

@github-actions github-actions Bot added the size/M Medium PR: 300-599 lines changed label May 26, 2026
@codecov
Copy link
Copy Markdown

codecov Bot commented May 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 68.83%. Comparing base (8fce30e) to head (215c6c9).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #5384   +/-   ##
=======================================
  Coverage   68.83%   68.83%           
=======================================
  Files         634      634           
  Lines       64422    64427    +5     
=======================================
+ Hits        44345    44349    +4     
- Misses      16794    16798    +4     
+ Partials     3283     3280    -3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@amirejaz amirejaz force-pushed the cimd-phase2-pr5-crd-field branch from e27ecdf to dff1dd5 Compare May 26, 2026 13:48
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels May 26, 2026
@amirejaz amirejaz force-pushed the cimd-phase2-pr5-crd-field branch from dff1dd5 to bf8f137 Compare May 26, 2026 14:47
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels May 26, 2026
@amirejaz amirejaz force-pushed the cimd-phase2-pr5-crd-field branch from bf8f137 to 04ee659 Compare May 26, 2026 17:40
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels May 26, 2026
Base automatically changed from cimd-phase2-pr3-wiring to main May 26, 2026 20:12
amirejaz and others added 3 commits May 27, 2026 02:08
C3 - Thread ScopesSupported into NewCIMDStorageDecorator so CIMD scope
     handling is consistent with DCR. Uses registration.ValidateScopes
     (same function as the DCR handler) to validate declared scopes
     against the AS allowlist and compute the effective scope list.
     When ScopesSupported is unset, the document's declared scopes are
     used directly; omitted scopes default to DefaultScopes.

C4 - Reject CIMD documents that declare grant_types or response_types
     the embedded AS does not support for public clients
     (authorization_code + refresh_token; code). Consistent with DCR
     which returns invalid_client_metadata for the same cases.

buildFositeClient now receives pre-computed scopes from fetch() rather
than re-parsing doc.Scope, matching the DCR handler pattern where scope
computation and validation happen before client construction.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
Adds EmbeddedAuthServerCIMDConfig to the CRD so operators can enable
CIMD through the normal VirtualMCPServer manifest workflow instead of
writing runconfig.json directly. Resolves the TODO(cimd) comment in
pkg/authserver/config.go.

The new cimd field on EmbeddedAuthServerConfig maps to
authserver.CIMDRunConfig in the generated RunConfig. CacheFallbackTTL
is stored as a Go duration string in the CRD (e.g. "5m") and parsed
to time.Duration by the converter.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
CIMDRunConfig.CacheFallbackTTL changed from time.Duration to string in
PR3. The operator converter now passes the string through unchanged;
parsing to time.Duration happens in resolveCIMDConfig in the runner,
after CIMDRunConfig.Validate() has already confirmed the format.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@amirejaz amirejaz force-pushed the cimd-phase2-pr5-crd-field branch from 04ee659 to 4f3e1cb Compare May 26, 2026 21:11
@amirejaz amirejaz changed the base branch from main to cimd-phase2-pr6-cimd-validation May 26, 2026 21:11
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels May 26, 2026
@amirejaz amirejaz force-pushed the cimd-phase2-pr6-cimd-validation branch 3 times, most recently from 8e68d45 to 36b5e97 Compare May 26, 2026 21:40
Base automatically changed from cimd-phase2-pr6-cimd-validation to main June 2, 2026 14:28
@amirejaz amirejaz marked this pull request as ready for review June 2, 2026 16:43
@amirejaz amirejaz requested review from JAORMX and jhrozek as code owners June 2, 2026 16:43
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 2, 2026
- Change cache_fallback_ttl validation from < 0 to <= 0 in
  CIMDRunConfig.Validate(). A zero TTL would expire every cache entry
  immediately, causing an outbound CIMD fetch on every authorize request.
- Add note to baselineClientScopes CRD field comment that when
  cimd.enabled is true, baseline scopes are also unioned into
  CIMD-resolved clients, including third-party ones.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@amirejaz amirejaz force-pushed the cimd-phase2-pr5-crd-field branch from 16a6c02 to dd5764d Compare June 2, 2026 19:34
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 2, 2026
Picks up the baselineClientScopes CIMD interaction note added in the
previous commit and includes EmbeddedAuthServerCIMDConfig in the
generated CRD API reference.

Co-Authored-By: Claude Sonnet 4.6 (1M context) <noreply@anthropic.com>
@github-actions github-actions Bot added size/M Medium PR: 300-599 lines changed and removed size/M Medium PR: 300-599 lines changed labels Jun 2, 2026
@amirejaz amirejaz requested a review from tgrunnagle June 2, 2026 22:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size/M Medium PR: 300-599 lines changed

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants